package com.rongshu.sendmessage.view.banner;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.rongshu.sendmessage.R;
import com.rongshu.sendmessage.bean.CarouselFigureList;
import com.rongshu.sendmessage.util.ObjectUtil;
import com.zhouwei.mzbanner.holder.MZViewHolder;

public class BannerViewHolder implements MZViewHolder<CarouselFigureList> {
    private ImageView mImageView;

    @Override
    public View createView(Context context) {
        // 返回页面布局
        View view = LayoutInflater.from(context).inflate(R.layout.banner_homeitem, null);
        mImageView = (ImageView) view.findViewById(R.id.banner_image);
        return view;
    }

    @Override
    public void onBind(Context context, int i, CarouselFigureList homeBannerData) {
        try {
            CornerTransform transformation = new CornerTransform(context, ObjectUtil.dip2px(context, 10));
            transformation.setExceptCorner(false, false, false, false);
            Glide.with(context)
                    .load(homeBannerData.getImgUrl())//Constant.HTTP_BASE +
                    .asBitmap()
                    .override(322, 144)
                    .skipMemoryCache(true)
                    .transform(new GlideRoundTransform(context))
                    .into(mImageView);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}